const async = require("async");
const lib = require("./lib.js");

const appPackage={
    'dnf':'com.tencent.tmgp.dnftest'
};

module.exports = {
    nowUser:0,
    setNow(now){
        this.nowUser = now
    },
    rightOffsetY(){
         if(this.nowUser == 1){
              return 100;  
         }
         return 0 
    },
    start(){
      lib.startApp(appPackage.dnf)
    },
    async tap(x,y,time=0){
      lib.tap(x,y);
        if(time>0){
           await lib.sleep(time)
        }
    },
    async back(){
        await this.tap(120,60,1500)
    },
    async openSelect(){
        console.log("点击设置按钮")
        //await this.tap(2260,240,1000)
        await lib.keyevent()
        await lib.sleep(1000)
        console.log("点击选择角色按钮")
        await this.tap(1483,960,5000)
    },
    async select($num = 1){
        this.setNow($num)
        console.log('选择角色：',$num)
        await this.tap(((($num-1)*400+180) +112),485,1000)
        console.log('开始进入角色')
        await this.tap(1180,1000,12000)
        console.log('开始进入角色END')
        // await lib.sleep(10000)
    },
    async meishi(type=0){
        console.log('【美食】','领取美食奖励',type)
        console.log('【美食】','点击福利按钮')
        await this.tap(1775,185,1000)
        console.log('【美食】','点击特色美食按钮')
        await this.tap(150,485,1500)
        console.log('【美食】','点击领取按钮')
        //上午
        type==0 && await this.tap(760,900,2300)
        //中午
        type==1 && await this.tap(1290,900,2300)
        //下午
        type==2 && await this.tap(1820,900,2300)

        console.log('【美食】','点击返回')
        await lib.keyevent()
        await lib.sleep(1000)
        //await this.back()
    },
    async heizhuan(){
        console.log('【黑钻】','点击福利按钮')
        await this.tap(1775,185,500)
        console.log('【黑钻】','点击黑钻特权按钮')
        await this.tap(147,292,800)
        console.log('【黑钻】','点击领取按钮')
        await this.tap(1300,1000,500)
        
        await this.tap(1260,255,500)
        await lib.sleep(200)
        console.log('【黑钻】','点击返回')
        await lib.keyevent()
        //await this.back()
    },
    async gonghui(){
        console.log('点击工会按钮')
        await this.tap(2235,590-this.rightOffsetY(),1000)
        console.log('点击签到按钮')
        await this.tap(150,370,1200)
        console.log('点击签到类型按钮')
        await this.tap(775,990,1200)
        console.log('点击签到确定按钮')
        await this.tap(1345,755,2000)
        await this.tap(1345,755,2000)
        console.log('点击签到关闭动画')
        await this.tap(1345,755,3000)
        await lib.sleep(3000)
        await this.back()
    },
    async weituo(){
        console.log('点击委托按钮')
        await this.tap(2215,745-this.rightOffsetY(),1500)
    },
    async wt_bls(){
        console.log('点击玻璃树按钮')
        await this.tap(900,700,1500)
        await this.tap(1900,980,1500)
        await this.tap(1365,670,2000)
        await this.tap(1365,670,3000)
        await this.back()
    },
    async wt_yjys(){
        console.log('点击异界陨石按钮')
        await this.tap(900,460,1500)
        await this.tap(1900,980,1500)
        await this.tap(1365,670,2000)
        await this.tap(1365,670,3000)
        await this.back()
    },
    async wt_mwzt(){
        console.log('点击迷惘之塔按钮')
        await this.tap(1850,245,1500)
        await this.tap(1765,1000,1500)
        await this.tap(1175,870,2000)
        await this.tap(1175,870,1000)
        await this.back()
    },
    async wt_gbl(){
        console.log('点击哥布林金库按钮')
        await this.tap(860,245,1500)
        await this.tap(1900,980,1500)
        await this.tap(1365,670,1000)
        await this.tap(1365,670,2000)
        await lib.sleep(5000)
        await this.back()
    },
    async wt_nbxg(){
        console.log('点击南部溪谷按钮')
        await this.tap(1850,950,1500)
        await this.tap(1670,980,1500)
        await this.tap(1365,670,1000)
        await this.tap(1365,670,2000)
        await this.back()
    },
    async bt_wt(nbxg=true){
      await this.weituo();

      nbxg && await this.wt_nbxg();
      await this.wt_bls();
      await this.wt_mwzt();
	  await this.wt_yjys();
      await this.wt_gbl();
    
      await this.back();
    },
    async mffhbi(){
        console.log('【复活币】','点击商城按钮')
        await this.tap(1900,70,1500)
		console.log('【复活币】','点击道具按钮')
        await this.tap(165,395,1500)
		console.log('【复活币】','点击恢复品按钮')
        await this.tap(880,160,1000)
        await this.tap(675,315,500)
		console.log('【复活币】','点击购买按钮')
        await this.tap(2000,1000,1000)
        await this.tap(1185,755,2000)
        await this.tap(1185,755,5300)
        await lib.sleep(2500)
        console.log('【复活币】','点击返回')
        await this.back();
    },
    async huizhang(){
        console.log('【徽章】','点击强化按钮')
        await this.tap(1800,1000,1200)
        console.log('【徽章】','点击徽章按钮')
        await this.tap(155,620,1200)
        console.log('【徽章】','点击快速合成按钮')
        await this.tap(2160,980,1200)
        console.log('【徽章】','点击选择按钮')
        await this.tap(1165,925,800)
        console.log('【徽章】','点击自动添加按钮')
        await this.tap(1200,950,500)
        console.log('【徽章】','点击合成按钮')
        await this.tap(1200,950,1000)
        console.log('【徽章】','点击确认合成按钮')
        await this.tap(1360,720,1800)
        console.log('【徽章】','点击关闭提示动画')
        await this.tap(2000,120,2000)
        console.log('【徽章】','点击关闭合成窗口')
        await this.tap(2000,120,7000)
        await this.back();
        console.log('【徽章】','点击返回按钮')
    },
    async lingqu() {
        console.log('点击成就按钮')
        await this.tap(1670,80,1200)
        await this.tap(2165,1000,1200)
        await this.tap(2165,1000,1000)
        await this.back();
    },
    async mail() {
        console.log('点击邮箱按钮')
        await this.tap(1800,425,1200)
        await this.tap(1400,1000,1500)
        await this.tap(420,1000,1500)
        await this.back();
    }
}